import {legacy_createStore as createStorage,combineReducers} from "redux"




function Msgreducer(state = {msg:'hello'},action){
    //具体修改数据的行为
    switch(action.type){
        case 'changeMsg':
            //约定修改的值叫payload
            state.msg = action.payload;
            //最后要return state 并且展开解除引用
            return {...state}
        case 'resetMsg':
            state.msg = "hello";
            return {...state}
         default:
            return {...state}   
    }
}

//多模块
function Numreducer(state = {num:21},action){
    switch(action.type){
        case 'addNum':
            //约定修改的值叫payload
            state.num += 1;
            //最后要return state 并且展开解除引用
            return {...state}
         default:
            return {...state}   
    }
}



//多模块

let reducer =  combineReducers({
    Msgreducer,
    Numreducer
})
let store =  createStorage(reducer)

export default store